package men.adg666.momo;

import android.content.Intent;
import android.graphics.Color;
import android.util.Log;
import android.view.View;

import java.io.IOException;
import java.util.ArrayList;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class WordDataHandle extends WordActivity {
    public  void getword(final String pages){
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    OkHttpClient client = new OkHttpClient();
                    Request request = new Request.Builder()
                            .url("http://momo.adg666.men/wordlist/" + pages + ".dat")
                            .build();
                    Response response = client.newCall(request).execute();
                    String responsedata = response.body().string();//获取单词库并解析
                    String[] wordlist = responsedata.split("#");//分割字符串
                    EnglishList = new String[wordlist.length];//英文词库
                    ChineseList = new String[wordlist.length];//中文词库
                    for (int i = 0; i < wordlist.length; i++) {
                        String[] newlist = wordlist[i].split("&");
                        ChineseList[i] = newlist[0];
                        EnglishList[i] = newlist[1];
                        Log.d("WordActivity", ChineseList[i]);
                    }
                    //分割字符串，获取内容
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }).start();

    }








}

